﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Service.BusinessLayer.Entities;
using Service.DataAccess.DataAccessHelper;
using System.Data.SqlClient;
using System.Data;

namespace Service.DataAccess.DataAccessLogic
{
    public class KhachHang_DA
    {
        public void them(KhachHang kh)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[7];
            par[0] = new SqlParameter("@hokh", kh.Hokh);
            par[1] = new SqlParameter("@tenkh", kh.Tenkh);
            par[2] = new SqlParameter("@gioitinh", kh.Gioitinh);
            par[4] = new SqlParameter("@diachi", kh.Diachi);
            par[3] = new SqlParameter("@sdt", kh.Sdt);
            par[5] = new SqlParameter("@tentk", kh.Tentaikhoan);
            par[6] = new SqlParameter("@matkhau", kh.Matkhau);
            help.InsertQuery("sp_khachhang_them", par);
        }
        public void sua(KhachHang kh)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[6];
            par[0] = new SqlParameter("@MaKH", kh.Makh);
            par[1] = new SqlParameter("@hokh", kh.Hokh);
            par[2] = new SqlParameter("@tenkh", kh.Tenkh);
            par[3] = new SqlParameter("@gioitinh", kh.Gioitinh);
            par[4] = new SqlParameter("@diachi", kh.Diachi);
            par[5] = new SqlParameter("@sdt", kh.Sdt);            
            help.UpdateQuery("sp_khachhang_sua", par);
        }
        public void xoa(int makh)
        {
            Helper help = new Helper();
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@makh", makh);
            help.DeleteQuery("sp_khachhang_xoa", par);
        }
        public DataSet layds_HoTen()
        {
            Helper help = new Helper();
            DataSet dskh = new DataSet();
            dskh = help.SelectQuery("sp_khachhang_layds_hoten");
            return dskh;
        }
        public DataSet layds()
        {
            Helper help = new Helper();
            DataSet dskh = new DataSet();
            dskh = help.SelectQuery("sp_khachhang_layds");
            return dskh;
        }
        public DataSet LayDS_Theo_TimKiem(string thongtin)
        {
            Helper help = new Helper();
            DataSet dskh = new DataSet();
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@ThongTin", thongtin);
            dskh = help.SelectQuery("sp_TimKiem_KhachHang", par);
            return dskh;
        }
        public DataSet LayDS_CTNhapXuat_Theo_MaKH(int MaKH)
        {
            Helper help = new Helper();
            DataSet dskh = new DataSet();
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@MaKH", MaKH);
            dskh = help.SelectQuery("sp_DSCTNhapXuat_Theo_MaKH", par);
            return dskh;
        }
        public DataSet LayDS_TKKH_ChucNangTenMH_LoaiWash(string tenmh, string tenwash)
        {
            Helper help = new Helper();
            DataSet dskh = new DataSet();
            SqlParameter[] par = new SqlParameter[2];
            par[0] = new SqlParameter("@TTChucNangH", tenmh);
            par[1] = new SqlParameter("@TTChucNangW", tenwash);
            dskh = help.SelectQuery("sp_TimKiem_KH_ChucNang", par);
            return dskh;
        }
        public DataSet LayDS_TKKH_ChucNangTenMH(string tenmh)
        {
            Helper help = new Helper();
            DataSet dskh = new DataSet();
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@TTChucNangH", tenmh);
            dskh = help.SelectQuery("sp_TimKiem_KH_ChucNang1", par);
            return dskh;
        }
        public DataSet LayDS_TKKH_ChucNangLoaiWash(string tenwash)
        {
            Helper help = new Helper();
            DataSet dskh = new DataSet();
            SqlParameter[] par = new SqlParameter[1];
            par[0] = new SqlParameter("@TTChucNangW", tenwash);
            dskh = help.SelectQuery("sp_TimKiem_KH_ChucNang2", par);
            return dskh;
        }
    }
}
